'use strict';

angular.module('homepageApp')
    .filter('searchFilters', function () {
        return function (input, searchString) {
            if(!searchString){
                return input;
            }
            var result = [];
            searchString = searchString.toLowerCase();
            // Using the forEach helper method to loop through the array
            angular.forEach(input, function(post){
                if(post.title.S.toLowerCase().indexOf(searchString) !== -1 || post.post.S.toLowerCase().indexOf(searchString) !== -1 ){
                    result.push(post);
                }
            });
            return result;
        };
    });